package com.lovestudying.service.impl;

import java.util.HashMap;
import java.util.Map;

import com.lovestudying.dao.VideoDao;
import com.lovestudying.dao.Impl.VideoDaoImpl;
import com.lovestudying.entity.Video;
import com.lovestudying.service.VideoService;
import com.lovestudying.util.PageInfo;

public class VideoServiceImpl implements VideoService {
	VideoDao VideoDao = new VideoDaoImpl();

	@Override
	public PageInfo<Video> getVideosByCourseId(String courseId) {

		Map<String, Object> Where_Param = new HashMap<String, Object>();
		// TODO 自动生成的方法存根
		Where_Param.put("course.course_id", courseId);
		return VideoDao.findVideo_Where_OrderBy_Limit(Where_Param, null, null, null);
	}

	@Override
	public PageInfo<Video> getVideosByCourseId(String courseId, String orderBy, String desc, Integer pageSize,
			Integer pageNum) {
		Map<String, Object> Where_Param = new HashMap<String, Object>();
		Where_Param.put("course.course_id", courseId);
		Map<String, Object> OrdeBy_Param = new HashMap<>();
		OrdeBy_Param.put(orderBy, desc);
		return VideoDao.findVideo_Where_OrderBy_Limit(Where_Param, OrdeBy_Param, pageSize, pageNum);
	}

	@Override
	public Boolean addVideo(String getUUID, String videoTitle, String courseUuid, String videoAddr) {
		Map<String, Object> Value_Param = new HashMap<>();
		// TODO 自动生成的方法存根
		Value_Param.put("video_id", getUUID);
		Value_Param.put("video_title", videoTitle);
		Value_Param.put("course_id", courseUuid);
		Value_Param.put("video_address", videoAddr);
		if (VideoDao.InsertVideo(Value_Param) == 1) {
			return true;
		} else {
			return false;
		}
	}
}
